Bug #19473. If you pass an allocator to std::function, we should use that allocator, not construct one from scratch. Add a test to make sure git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@206623 91177308-0d34-0410-b5e6-96231b3b80d8 
diff --git a/include/functional b/include/functional index 891ed46..167790b 100644 --- a/include/functional +++ b/include/functional 
@@ -1617,21 +1617,22 @@  if (__not_null(__f))  {  typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF; - if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) + typedef typename __alloc_traits::template +#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES + rebind_alloc<_FF> +#else + rebind_alloc<_FF>::other +#endif + _Ap; + _Ap __a(__a0); + if (sizeof(_FF) <= sizeof(__buf_) &&  + is_nothrow_copy_constructible<_Fp>::value && is_nothrow_copy_constructible<_Ap>::value)  {  __f_ = (__base*)&__buf_; - ::new (__f_) _FF(_VSTD::move(__f)); + ::new (__f_) _FF(_VSTD::move(__f), _Alloc(__a));  }  else  { - typedef typename __alloc_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<_FF> -#else - rebind_alloc<_FF>::other -#endif - _Ap; - _Ap __a(__a0);  typedef __allocator_destructor<_Ap> _Dp;  unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));  ::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a));